<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>阅读题目</title>
<style>
.cl{width:95%; margin:60px auto;}
.ans{ width:1200px; margin:60px auto;}
</style>
    <script src="/cn/js/jquery-1.12.2.min.js"></script>
<script type="text/javascript" src="/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="/ueditor/ueditor.all.min.js"></script>
<!-- 编辑器公式插件 -->
<script type="text/javascript" charset="utf-8" src="/ueditor/kityformula-plugin/addKityFormulaDialog.js"></script>
<script type="text/javascript" charset="utf-8" src="/ueditor/kityformula-plugin/getKfContent.js"></script>
<script type="text/javascript" charset="utf-8" src="/ueditor/kityformula-plugin/defaultFilterFix.js"></script>
</head>
<body>
<div>填空题题目格式处理</div>
<div id="wrapper" class="cl">
    <form action="">
        <div class="controls">
           <textarea  id="editor" class="editor" name="value"></textarea>
        </div>
        <button type="button" class="update">填空题题目生成</button>
        <div>
            <p>备用方法：</p>
<!--            开始题号<input class="num" type="text">-->
            <button type="button" class="update2">备用生成方法</button>
        </div>
    </form>
</div>
<div  class="ans">

<div>


<script type="text/plain" id="j_ueditorupload"></script>
</body>
</html>
<script>var editor = UE.getEditor('editor');</script>
<script>
    
    $('.update').click(function () {
        var text = editor.getContent();
        if(text){
            var reg = /style=\"(.*?)\"/gi;
            var reg2 = /class=\"(.*?)\"/gi;
            text = text.replace(reg,'');
            text = text.replace(reg2,'');
            //text = text.replace(/<input(.*?)\/>/ig,'<input />');
            text = text.replace(/<input[^>]*placeholder=['"]([^'"]*)[^>]*>/gi,'<input class="BlankInput" type="text" placeholder="$1"/>');
            text = text.replace(/<div(.*?)>/ig,'<div>');
            text = text.replace(/<p(.*?)>/ig,'<p>');

            $('.ans').text(text);
        }

    })

    $(".update2").click(function(){
        // var num = $('.num').val();
        // if($.trim(num)==''){
        //     alert('请填写开始题号');
        //     return false;
        // }
        // 带格式
        var text = editor.getContent();
        if(text){
            var reg = /style=\"(.*?)\"/gi;
            var reg2 = /class=\"(.*?)\"/gi;
            text = text.replace(reg,'');
            text = text.replace(reg2,'');
            text = text.replace(/<input(.*?)\/>/ig,'<input/>');
            text = text.replace(/<div(.*?)>/ig,'<div>');
            text = text.replace(/<p(.*?)>/ig,'<p>');
            $('.ans').text(text);
        }
    });
</script>
<script>
    //实例化编辑器
    var o_ueditorupload = UE.getEditor('j_ueditorupload',
        {
            autoHeightEnabled: false
        });
    o_ueditorupload.ready(function () {

        o_ueditorupload.hide();//隐藏编辑器

        o_ueditorupload.addListener('afterUpfile', function (t, arg) {
            $('.file').val(arg[0].url);
        });
    });

    // 弹出文件上传的对话框
    function upFiles() {
        var myFiles = o_ueditorupload.getDialog("attachment");
        myFiles.open();
    }
</script>


